package org.setec.config;

import org.setec.utils.io.Persistance;

import java.lang.reflect.Method;

public class InterpretableConfiguration extends Configuration {

    public boolean isProcessRealMethod(String className, String methodName, Object[] args) {
        if (getMode().equals(Mode.LEARN) ||
                getMode().equals(Mode.PASS)) {
            return true;
        }

        if (getMode().equals( Mode.AUTO)) {
            return !Persistance.persists(getStorage(), className, methodName, args);
        }

        return false;
    }

    public boolean isLearn(String className, String methodName, Object[] args) {
        if (getMode().equals(Mode.LEARN)) {
            return true;
        }

        if (getMode().equals(Mode.AUTO)) {
            return !Persistance.persists(getStorage(), className, methodName, args);
        }

        return false;
    }

    public boolean isMock(String className, String methodName, Object[] args) {
        if( getMode().equals(Mode.MOCK )) {
            return true;
        }
        if( getMode().equals( Mode.AUTO) ) {
            Persistance.persists(getStorage(), className, methodName, args);
        }
        return false;
    }

}
